home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / prgtools / tn2.zip / EASTER.T < prev    next >
Text File  |  1996-11-15  |  2KB  |  85 lines

  1. %
  2. % "easter.t" computes the date of Easter
  3. %
  4. % Adapted from a BASIC program which appeared in 
  5. % Astronomical Computing, Sky & Telescope, March, 1986
  6. %
  7. %   Sample program for the T Interpreter by:
  8. %
  9. %   Stephen R. Schmitt
  10. %   962 Depot Road
  11. %   Boxborough, MA 01719
  12. %
  13.  
  14. program
  15.  
  16.     var year : int
  17.     var ans : string
  18.     label another :
  19.  
  20.     another :
  21.     
  22.     loop
  23.  
  24.         prompt "Year?"
  25.         get year
  26.         exit when year >= 1583
  27.  
  28.     end loop
  29.  
  30.     easter_day( year )
  31.  
  32.     prompt "Another? Y or N "
  33.     get ans
  34.  
  35.     if ans[0] = 'Y' or ans[0] = 'y' then
  36.         goto another
  37.     end if
  38.  
  39. end program
  40.  
  41. %
  42. % compute the date of easter for a year after 1582
  43. %
  44. procedure easter_day( y : int )
  45.  
  46.     var a, b, c, d, e, f, g, h, i, j, k, m, n, p : int
  47.     var temp : real
  48.     var mon : string
  49.  
  50.     temp := y / 19
  51.     a := floor( ( temp - floor( temp ) ) * 19 + 0.001 )
  52.  
  53.     temp := y / 100
  54.     b := floor( temp )
  55.     c := floor( ( temp - floor( temp ) ) * 100 + 0.001 )
  56.  
  57.     temp := b / 4
  58.     d := floor( temp )
  59.     e := floor( ( temp - floor( temp ) ) *4 + 0.001 )
  60.     f := floor( ( ( b + 8 ) / 25 ) + 0.001 )
  61.     g := floor( ( b - f + 1 ) / 3 )
  62.  
  63.     temp := ( 19 * a + b - d - g + 15 ) / 30
  64.     h := floor( ( temp - floor( temp ) ) * 30 + 0.001 )
  65.  
  66.     temp := c / 4
  67.     i := floor( temp )
  68.     j := floor( ( temp - i ) * 4 + 0.001 )
  69.  
  70.     temp := ( 32 + 2 * e + 2 * i - h - j ) / 7
  71.     k := floor( ( temp - floor( temp ) ) * 7 + 0.001 )
  72.     m := floor( ( a + 11 * h + 22 * k ) / 451 )
  73.  
  74.     temp := ( h + k - 7 * m + 114 ) / 31
  75.     n := floor( temp )
  76.     p := floor( ( temp - n ) * 31 + 0.001 )
  77.  
  78.     mon := "April "
  79.     if n = 3 then
  80.         mon := "March "
  81.     end if
  82.  
  83.     put "In ", y, " Easter is on: ", mon, p + 1
  84.  
  85. end procedure